package com.lly.schedule.serice.impl;

import com.lly.schedule.dao.SysUserDao;
import com.lly.schedule.dao.impl.SysUserDaoImpl;
import com.lly.schedule.pojo.SysUser;
import com.lly.schedule.serice.SysUserService;
import com.lly.schedule.util.MD5Util;

public class SysUserServiceImpl implements SysUserService {
    private SysUserDao sysUserDao=new SysUserDaoImpl();
    @Override
    public int addUser(SysUser sysUser) {
        //1.获取密码,然后设置密码
        int rows= 0;
        try {
            sysUser.setUserPwd(MD5Util.encrypt(sysUser.getUserPwd()));
            rows = sysUserDao.addUser(sysUser);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return rows;
    }

    @Override
    public SysUser login(String username) throws Exception {
        return sysUserDao.login(username);
    }
}
